package com.cskaoyan._01basic._08loop._02test;

import java.util.Scanner;

/**
 * @author Macro_Ray
 * @since 2024/3/4 12:32
 */
/* 键盘录入两个数，统计两个数之间满足既能被3整除又能被5整除的数字的个数*/

public class _03For_03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数表示开始");
        int num1 = sc.nextInt();
        System.out.println("请再输入一个整数表示结束");
        int num2 = sc.nextInt();

        int nums = 0;
        // 统计变量
        int count = 0;

        if (num1 < num2) {
            for (int i = num1; i <= num2; i++) {
                if (i % 3 == 0 && i % 5 == 0) {
                    nums = i;
                    System.out.println(nums);
                    count++;
                }
            }
        } else if (num1 > num2) {
            for (int i = num2; i <= num1; i++) {
                if (i % 3 == 0 && i % 5 == 0) {
                    nums = i;
                    System.out.println(nums);
                    count++;
                }
            }
        } else {
            System.out.println("两个整数不能相同，请重新输入");
        }
        System.out.println("一共有" + count + "个数字");


    }
}

